using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SiteECSWeb;

public partial class Offices_OfficeECSMap : PageBase
{
    static int EcsInternalOficeID = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            pnlEditOffList.Visible = ApplyManageForAuthonticatedUser(Page.User.Identity.Name,
                RolesName.AdminSystem, RolesName.Offices, RolesName.SysAdmin);
            InternalOfficeDataSource.FilterExpression = "Ecs_InternalOffice_ID  <> 7";
        }
    }
    protected void AccordionOfficeList_ItemDataBound(object sender, AjaxControlToolkit.AccordionItemEventArgs e)
    {
        EcsOfficeBLL OfficeAPI = new EcsOfficeBLL();

        if (e.ItemType == AjaxControlToolkit.AccordionItemType.Header)
        {
            EcsInternalOficeID = int.Parse(
                ((HiddenField)e.AccordionItem.FindControl("hfInternalOfficeID")).Value);

            Label lbTotaloffices = new Label();
            lbTotaloffices = (Label)e.AccordionItem.FindControl("lbTotalOffices");
            lbTotaloffices.Text = OfficeAPI.GetTotalOfficesByInternalID(EcsInternalOficeID).ToString();

        }
        if (e.ItemType == AjaxControlToolkit.AccordionItemType.Content)
        {
            DataList dlOfficeList = new DataList();
            dlOfficeList = (DataList)e.AccordionItem.FindControl("dlistAllOfficesList");
            dlOfficeList.DataSource = OfficeAPI.GetEcsOfficeByInternalID(EcsInternalOficeID);
            dlOfficeList.DataBind();
        }
    }
}
